var Logger = function() {
	this.container = document.createElement('div');
	//this.container.style.width = '240px';
	this.container.style.height = '300px';
	this.container.style.margin = '0 auto';
	this.container.style.fontSize = '10px';
	this.container.style.color = '#1ABC9C';
	this.container.style.borderTop = this.container.style.borderRight = '1px solid #333';
	this.container.style.padding = '5px';
	this.container.style.overflowY = 'scroll';

	this.fixedable = (function() {
		var o = document.createElement("div"),
			r;
		o.style.position = "fixed";
		o.style.top = 0;
		document.body.appendChild(o);
		r = !isNaN(o.offsetTop) && parseInt(o.offsetTop) === 0;
		o.parentNode.removeChild(o);
		o = null;
		return r;
	})();

	if (this.fixedable) {
		this.container.style.position = 'fixed';
	};

	this.container.style.left = 0;
	this.container.style.bottom = 0;

	document.body.appendChild(this.container);

	/**
	 * 打印日志，只负责输出，可以提供一个数据对象的转换方法
	 * @param  {Object}   msg      任意对象
	 * @param  {Function} transfer 转换方法
	 */
	this.log = function(msg, transfer) {
		var time = getTime('hh-mm-ss');

		if (typeof transfer == 'function') {
			msg = transfer(msg);
		};
		this.container.appendChild(document.createTextNode(time + ' ----- ' + msg));
		this.container.appendChild(document.createElement('br'));
	};

	function getTime(format) {
		var now = new Date();
		var o = {
			"M+": now.getMonth() + 1,
			"d+": now.getDate(),
			"h+": now.getHours(),
			"m+": now.getMinutes(),
			"s+": now.getSeconds(),
			"q+": Math.floor((now.getMonth() + 3) / 3),
			"S": now.getMilliseconds()
		};
		if (/(y+)/.test(format)) {
			format = format.replace(RegExp.$1, (now.getFullYear() + "").substr(4 - RegExp.$1.length));
		}
		for (var i in o) {
			if (new RegExp("(" + i + ")").test(format)) {
				format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[i] : ("00" + o[i]).substr(("" + o[i]).length));
			}
		}
		return format;
	}

};